<!DOCTYPE html>
{% load static %}
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>User Center - DreamLife</title>
    <link rel="icon" type="image/x-icon" href="{% static 'img/icon.ico' %}">
    <style>
        /* CSS样式可以根据需要自行添加 */
        /* 页面居中显示 */
        body {
            background-image: url("{% static 'img/myimg.jpg' %}");
            background-size: cover;
            background-repeat: no-repeat;
            background-attachment: fixed; /* 保持背景图固定不随滚动而移动 */
            background-position: center;
            display: flex;
            justify-content: center;
            align-items: center;
            font-family: Arial, sans-serif;
        }
        /* 取消超链接的下划线并将初始字体颜色设置为黑色 */
        a {
            text-decoration: none;
            color: black;
            /* 其他样式 */
        }
        button a {
            text-decoration: none;
            color: black;
            border: 1px solid #555; /* 深灰色边框 */
            border-radius: 5px; /* 圆角边框 */
            padding: 5px 10px; /* 按钮内边距 */
            /* 其他样式 */
        }

        /* 点击后保持字体颜色为黑色 */
        a:visited {
            color: black; /* 设置点击后的字体颜色为黑色 */
        }
        /* 整体容器 */
        .container {
            width: 80%; /* 调整宽度 */
            background-color: rgba(255, 255, 255, 0.6); /* 设置背景色并调整透明度 */
            backdrop-filter: blur(10px); /* 添加毛玻璃效果 */
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
        }

        /* 导航栏 */
        .navbar {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background-color: #999;
            color: white;
            padding: 10px 20px;
            border-radius: 4px;
        }
        .navbar button {
            color: white;
            background-color: transparent;
            border: none;
            cursor: pointer;
        }
        .search {
            width: 200px; /* 调整搜索框宽度 */
        }
        /* 用户信息 */
        .user-info {
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-top: 20px;
        }
        .user-info img {
            max-width: 100px;
            border-radius: 50%;
            margin-bottom: 10px;
        }
        /* 用户文章 */
        .user-articles {
            margin-top: 20px;
        }
        .article {
            background-color: white;
            padding: 10px;
            margin-bottom: 10px;
            border-radius: 4px;
            box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>
    <div class="container">
        <!-- 导航栏 -->
        <div class="navbar">
            <button><a href="/user/centre/{{ usrname }}">返回</a></button>
            <button><a href="/">首页</a></button>
            <button><a href="/blog/edit/">写博客</a></button>
            <form action="{% url 'search_results' usrname=usrname %}" method="GET">
                <input type="text" class="search" placeholder="Search for something!!!" name="query">
                <button type="submit">搜索</button>
            </form>
            <button><a href="/blog/archieve/{{ current_user }}">我的博客</a></button>
            <button><a href="/user/centre/{{ current_user }}">我的主页</a></button>
            <button><a href="/user/edit/">信息编辑</a></button>
            <button><a href="/user/logout/">退出</a></button>

        </div>

        <!-- 主体内容 -->
{#        <div class="user-info">#}
{#            <img src="{% static "img/userhead.png" %}" alt="User Avatar">#}
{#            <h2>{{ usrname }}</h2>#}
{#            <p>关注: {% if following %}{{ following.count }}{% else %}无{% endif %}</p>#}
{#            <p>粉丝: {% if followers %}{{ followers.count }}{% else %}无{% endif %}</p>#}
{#        </div>#}

        <!-- 搜索结果 -->
        <div class="user-articles">
            <h2>'{{ usrname }}'的文章中搜索'{{ query }}'结果</h2>
            {% if search_results %}
                {% for result in search_results %}
                    <a href="{% url 'blog:article_detail' usrname=result.author.username aid=result.pk %}" class="article-link">
                        <div class="article">
                            <h3>{{ result.title }}</h3>
{#                            <p>{{ result.first_paragraph }}</p>#}
                            <p>{{ result.abstract }}</p>
                        </div>
                    </a>
                {% endfor %}
            {% else %}
                <p>没有找到匹配的结果。</p>
            {% endif %}
        </div>

    </div>
</body>
</html>
